<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title>编辑</title>
    <!-- 引入Bootstrap CSS -->
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.3.2/css/bootstrap.min.css">
</head>

<body>
    <h1>编辑文章</h1>
    <form action="#" th:action="@{/article/save}" th:if="${article!=null}" th:object="${article}" method="POST" class="mb-3">
        <input type="hidden" name="id" th:value="*{id}" />
        <div class="mb-3">
            <label for="title" class="form-label">标题</label>
            <input type="text" class="form-control" id="title" th:field="*{title}" placeholder="标题" required>
        </div>
        <div class="mb-3">
            <label for="typeId" class="form-label">文章类型</label>
            <select class="form-select" id="typeId" name="typeId" required>
                <option value=""> -- 文章类型 -- </option>
                <option th:selected="${article.articletype.id == c.id}" th:each="c : ${typeList}" th:value="${c.id}" th:text="${c.type}"></option>
            </select>
        </div>
        <div class="mb-3">
            <label for="content" class="form-label">内容</label>
            <textarea class="form-control" id="content" rows="6" th:field="*{content}" placeholder="文章内容" required></textarea>
        </div>
        <button type="submit" class="btn btn-primary">保存</button>
    </form>

    <a th:href="@{/article/findAll}" class="btn btn-secondary">返回文章类型列表</a>
</body>
<!-- 引入Bootstrap JS -->
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.3.2/js/bootstrap.bundle.min.js"></script>
</html>